package com.xkang.util;

import cn.hutool.core.io.file.FileReader;
import com.xkang.model.MetaSchema;

import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class FakeUtils {

    public static List<MetaSchema> parseMetaSchema(String filePath){
        ArrayList<MetaSchema> schemas = new ArrayList<>() ;
        FileReader fileReader = FileReader.create(new File(filePath));
        List<String> lines = fileReader.readLines();
        for (String line : lines) {
            String[] words = line.split("||");
            MetaSchema metaSchema = new MetaSchema();
            metaSchema.setName(words[0]);
            metaSchema.setType(words[1]);
            metaSchema.setComment(words[2]);
            metaSchema.setCommand(RegUtils.reg_all_keywords(words[2]));
            schemas.add(metaSchema) ;
        }
        return schemas ;
    }

    public static Object fake_enum(Object[] args){
        int len = args.length ;
        Random random = new Random();
        int i = random.nextInt(len);
        return args[i] ;
    }
}
